package main

import (
	"booking/common/logger"
	"booking/config"
	"booking/internal/queue/test"
	"booking/locales"
	"booking/models"
	"time"

	"github.com/hibiken/asynq"
	"github.com/spf13/viper"
)

func main() {
	time.Local = time.UTC
	config.Init()
	locales.Init()
	models.Database()
	models.Redis()
	srv := asynq.NewServer(
		asynq.RedisClientOpt{
			Addr:     viper.GetString("redis.host"),
			Username: viper.GetString("redis.username"),
			Password: viper.GetString("redis.password"),
			DB:       viper.GetInt("redis.db"),
		},
		asynq.Config{
			Concurrency: 2,
			Queues: map[string]int{
				"test":    1,
				"default": 1,
			},
		},
	)
	mux := asynq.NewServeMux()

	mux.HandleFunc("test", test.Queue)

	if err := srv.Run(mux); err != nil {
		logger.Fatal(err)
	}
}
